<template>
	<view>
		<!-- 自定义导航 -->
		<custom-navbar :title='title' bgColor='#0081ff' navbarStyle='custom'></custom-navbar>
		<!-- 查询模块 -->
		<view class="width padding">
			<view class="searchModule" @click="checkDate">
				<view class="flex-row height-bth">
					<view class="text-black text-bold text-d " style="width: 150rpx;">时间选择</view>
					<view class="searchContent ">
						<view class="flex-sub">{{dateShow}}</view>
						<view class="cuIcon-triangledownfill" style="font-size: 40rpx;" />
					</view>
				</view>
			</view>
			<view class="width height-xl flex-allCenter margin-top-xl" @click="queryOrder">
				<button class="cu-btn lg bg-orange width-btn">查询</button>
			</view>

		</view>
		<!-- 查询时间选择器 -->
		<u-datetime-picker :show="show" v-model="dateSearch" :min-date="min" mode="year-month" @cancel="cancelDate()"
			@confirm="confirmDate"></u-datetime-picker>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title: '订单查询',
				show: false,//显示时间选择器
				dateSearch: Number(new Date()),//日期选择器当天时间
				dateShow: '',//显示时间选择值
				dateValue: '',//时间选择的值
				min: (Math.floor(Date.now() / 1000) - 31536000) * 1000 // 大约一年的秒数
			}
		},
		methods: {
			checkDate() {
				this.show = true;
			},
			/**关闭日期查询*/
			cancelDate() {
				this.show = false;
			},
			/**确认日期*/
			confirmDate(e) {
				// 创建日期对象
				const date = new Date(e.value);
				// 获取年份
				const year = date.getFullYear();
				// 获取月份（注意月份从0开始计数，所以需要加1）
				const month = String(date.getMonth() + 1).padStart(2, '0');
				this.dateShow = `${year}-${month}`;
				this.dateValue = e.value;
				this.show = false;
			},
			/**跳转查询信息页*/
			queryOrder(){
				if(this.dateValue==''||this.dateValue==null){
					this.$modal.msg('未选择日期')
				}else{
					this.$tab.navigateTo(`/pages/order/orderInfo?dateValue=${this.dateValue}`)
				}
				
			}
		}
	}
</script>

<style>
	.searchModule {
		width: 100%;
		height: 200rpx;
		display: flex;
		flex-direction: column;
		justify-content: center;
		padding: 20rpx 20rpx;
		background-color: #fff;
		border-radius: 12rpx;
	}

	.searchContent {
		flex: 1;
		display: flex;
		align-items: center;
		height: 80rpx;
		padding: 0 15rpx;
		border: 1rpx #333 solid;
		border-radius: 12rpx;
	}
</style>